import requests

# 8、异常处理

def getHtml123(url):

    try:
        res = requests.get(url)
        print(res.status_code)
        res.raise_for_status()
        print(res.text)
    except:
        print("get http error!")


if __name__=="__main__":
    url = "https://www.baidu.com"
    getHtml123(url)